home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 15 / CU Amiga Magazine's Super CD-ROM 15 (1997)(EMAP Images)(GB)[!][issue 1997-10].iso / CUCD / Graphics / Ghostscript / source / sjpege.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-03-23  |  3.2 KB  |  111 lines

  1. /* Copyright (C) 1994 Aladdin Enterprises.  All rights reserved.
  2.   
  3.   This file is part of Aladdin Ghostscript.
  4.   
  5.   Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author
  6.   or distributor accepts any responsibility for the consequences of using it,
  7.   or for whether it serves any particular purpose or works at all, unless he
  8.   or she says so in writing.  Refer to the Aladdin Ghostscript Free Public
  9.   License (the "License") for full details.
  10.   
  11.   Every copy of Aladdin Ghostscript must include a copy of the License,
  12.   normally in a plain ASCII text file named PUBLIC.  The License grants you
  13.   the right to copy, modify and redistribute Aladdin Ghostscript, but only
  14.   under certain conditions described in the License.  Among other things, the
  15.   License requires that the copyright notice and this notice be preserved on
  16.   all copies.
  17. */
  18.  
  19. /* sjpege.c */
  20. /* Interface routines for IJG encoding code. */
  21. #include "stdio_.h"
  22. #include "string_.h"
  23. #include "jpeglib.h"
  24. #include "jerror.h"
  25. #include "gx.h"
  26. #include "gserrors.h"
  27. #include "strimpl.h"
  28. #include "sdct.h"
  29. #include "sjpeg.h"
  30.  
  31. /*
  32.  * Interface routines.  This layer of routines exists solely to limit
  33.  * side-effects from using setjmp.
  34.  */
  35.  
  36. int
  37. gs_jpeg_create_compress (stream_DCT_state *st)
  38. {    /* Initialize error handling */
  39.     gs_jpeg_error_setup(st);
  40.     /* Establish the setjmp return context for gs_jpeg_error_exit to use. */
  41.     if (setjmp(st->data.common->exit_jmpbuf))
  42.         return_error(gs_jpeg_log_error(st));
  43.  
  44.     jpeg_create_compress(&st->data.compress->cinfo);
  45.     return 0;
  46. }
  47.  
  48. int
  49. gs_jpeg_set_defaults (stream_DCT_state *st)
  50. {    if (setjmp(st->data.common->exit_jmpbuf))
  51.         return_error(gs_jpeg_log_error(st));
  52.     jpeg_set_defaults(&st->data.compress->cinfo);
  53.     return 0;
  54. }
  55.  
  56. int
  57. gs_jpeg_set_colorspace (stream_DCT_state *st,
  58.             J_COLOR_SPACE colorspace)
  59. {    if (setjmp(st->data.common->exit_jmpbuf))
  60.         return_error(gs_jpeg_log_error(st));
  61.     jpeg_set_colorspace(&st->data.compress->cinfo, colorspace);
  62.     return 0;
  63. }
  64.  
  65. int
  66. gs_jpeg_set_linear_quality (stream_DCT_state *st,
  67.                 int scale_factor, boolean force_baseline)
  68. {    if (setjmp(st->data.common->exit_jmpbuf))
  69.         return_error(gs_jpeg_log_error(st));
  70.     jpeg_set_linear_quality(&st->data.compress->cinfo,
  71.                 scale_factor, force_baseline);
  72.     return 0;
  73. }
  74.  
  75. int
  76. gs_jpeg_set_quality (stream_DCT_state *st,
  77.              int quality, boolean force_baseline)
  78. {    if (setjmp(st->data.common->exit_jmpbuf))
  79.         return_error(gs_jpeg_log_error(st));
  80.     jpeg_set_quality(&st->data.compress->cinfo,
  81.              quality, force_baseline);
  82.     return 0;
  83. }
  84.  
  85. int
  86. gs_jpeg_start_compress (stream_DCT_state *st,
  87.             boolean write_all_tables)
  88. {    if (setjmp(st->data.common->exit_jmpbuf))
  89.         return_error(gs_jpeg_log_error(st));
  90.     jpeg_start_compress(&st->data.compress->cinfo, write_all_tables);
  91.     return 0;
  92. }
  93.  
  94. int
  95. gs_jpeg_write_scanlines (stream_DCT_state *st,
  96.              JSAMPARRAY scanlines,
  97.              int num_lines)
  98. {    if (setjmp(st->data.common->exit_jmpbuf))
  99.         return_error(gs_jpeg_log_error(st));
  100.     return (int) jpeg_write_scanlines(&st->data.compress->cinfo,
  101.                       scanlines, (JDIMENSION) num_lines);
  102. }
  103.  
  104. int
  105. gs_jpeg_finish_compress (stream_DCT_state *st)
  106. {    if (setjmp(st->data.common->exit_jmpbuf))
  107.         return_error(gs_jpeg_log_error(st));
  108.     jpeg_finish_compress(&st->data.compress->cinfo);
  109.     return 0;
  110. }
  111.